import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'   //国际化
import { createPinia } from 'pinia'
import formCreate from '@form-create/element-ui'
import indexDB from "./utils/storage/index.ts";
await indexDB.init(); // 在入口函数初始化
const app = createApp(App);
// 实例化 Pinia
const pinia = createPinia()
type Filter = {
  format: <T>(str: T) => string
}

// 声明要扩充 @vue/runtime-core 包的声明
// 这里扩充 ComponentCustomProperties 接口，因为它是 vue3 中实例的属性的类型
declare module '@vuerunt/ime-core' {
  export interface ComponentCustomProperties {
    $filters: Filter
  }
}

app.config.globalProperties.$filters = {
  format<T>(str: T): string {
    return `真·${str}`
  }
}
app.use(ElementPlus,{locale: zhCn}).use(router).use(pinia).use(formCreate).mount('#app')

//全局注册图标组件
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
